package com.lz.service;

import java.sql.Connection;
import java.util.List;

import com.lz.dao.CategoryDAO;
import com.lz.form.ItemCategoryDTO;
import com.lz.util.ConnMgr;
public class ItemCategoryService{

public static void createBookcategory(ItemCategoryDTO dto){

Connection conn=ConnMgr.getConnection();
CategoryDAO dao=new CategoryDAO();
dao.create(conn,dto);
try{
conn.close();
}catch(Exception e){
conn=null;
}finally{conn=null;}

}

public static void updateBookcategory(ItemCategoryDTO dto){

Connection conn=ConnMgr.getConnection();
CategoryDAO dao=new CategoryDAO();
dao.update(conn,dto);
try{
conn.close();
}catch(Exception e){
conn=null;
}finally{conn=null;}

}

public static void deleteBookcategory(ItemCategoryDTO dto){

Connection conn=ConnMgr.getConnection();
CategoryDAO dao=new CategoryDAO();
dao.delete(conn,dto);
try{
conn.close();
}catch(Exception e){
conn=null;
}finally{conn=null;}

}
//The input DTO object needs to contain only the primary keys. Other values will be populated by the DAO

public static ItemCategoryDTO populateBookcategory(ItemCategoryDTO dto){

Connection conn=ConnMgr.getConnection();
CategoryDAO dao=new CategoryDAO();
dto=dao.populate(conn,dto);
try{
conn.close();
}catch(Exception e){
conn=null;
}finally{conn=null;}
return dto;

}

public static List getAllCategory(){

Connection conn=ConnMgr.getConnection();
CategoryDAO dao=new CategoryDAO();
List list= dao.getAll(conn);
try{
conn.close();
}catch(Exception e){
conn=null;
}finally{conn=null;}
return list;

}

}//eof class